<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试登录</title>
    <script src="jquery-3.5.1.min.js"></script>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background-color: #f0f0f0;
        }

        .login-container {
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            width: 300px;
        }

        .login-header {
            background-color: #3498db;
            color: #fff;
            padding: 20px;
            text-align: center;
        }

        .login-header h2 {
            margin: 0;
            font-size: 24px;
        }

        .login-form {
            padding: 20px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            font-weight: bold;
            margin-bottom: 5px;
            color: #333;
        }

        input {
            width: 100%;
            padding: 10px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 14px;
        }

        .login-btn {
            width: 100%;
            padding: 12px;
            background-color: #3498db;
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }

        .login-btn:hover {
            background-color: #2980b9;
        }

        .mask {
            width: 100%;
            height: 100%;
            position: fixed;
            top: 0;
            left: 0;
            display: none;
            background-color: rgba(0, 0, 0, 0.6);
        }

        .mask .loading {
            width: 200px;
            height: 100px;
            background-color: #fff;
            margin: 150px auto;
            text-align: center;
            line-height: 100px;
        }
    </style>
</head>

<body>

<div class="login-container">
    <div class="login-header">
        <h2>承运商回单</h2>
    </div>
    <div class="login-form">
        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" id="username" placeholder="请输入用户名">
        </div>
        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" id="password" placeholder="请输入密码">
        </div>
        <button class="login-btn" onclick="login()">Login</button>
    </div>
</div>

<div class="mask" id="mask">
    <div class="loading">
        Loading...
    </div>
</div>

<script>

    function login() {
        //1、封装：json数据
        //1-1：账号
        var username = document.getElementById('username').value;
        //1-2：密码
        var password = document.getElementById('password').value;
        //1-3：封装 json 数据
        var jsonData = {
            username: username,
            password: password
        };
        showLoading();
        //2、发送 POST 请求
        $.ajax({
            url: 'https://web.woer.com/prod-api/web/carrier/getToken',
            type: 'POST',
            contentType: 'application/json',
            data: JSON.stringify(jsonData),
            success: function (response) {
                closeLoading();
                // 请求成功时的处理
                console.log(response);
                if(response.code!=200){
                    alert(response.msg);
                    return;
                }
                var token=response.data;
                document.location.href='carrierPhotoUpload.html?token='+token;
            },
            error: function (error) {
                closeLoading();
                // 请求失败时的处理
                alert('请求失败');
            }
        });
    }

    function showLoading() {
        document.getElementById("mask").style.display = "block";
    }
    function closeLoading() {
        document.getElementById("mask").style.display = "none";
    }
</script>

</body>

</html>